Skip to content

Conversation

@freddieknets
Copy link
Collaborator

Description

  • Allow python-only attributes in a HybridClass by defining them with _extra_fields_in_to_dict on the class (it was not possible to automatically recognise python-only attributes from _store_in_to_dict)
  • Added a test which also demonstrates how the __init__ should be adapted correctly when using python-only attributes
  • Make the to_dict method cascade into using the existing _to_json if available (e.g. for xofields that are Structs), which resolves deeper
  • All tests pass, including in xtrack and xfields

Checklist

Mandatory:

  • I have added tests to cover my changes
  • All the tests are passing, including my new ones
  • I described my changes in this PR description

Optional:

  • The code I wrote follows good style practices (see PEP 8 and PEP 20).
  • I have updated the docs in relation to my changes, if applicable
  • I have tested also GPU contexts

@giadarol giadarol changed the base branch from main to release/0.5.5 October 30, 2025 07:48
@giadarol giadarol merged commit 2e034f3 into xsuite:release/0.5.5 Oct 30, 2025
1 check passed
@freddieknets freddieknets deleted the PythonVarsInHybridClass branch November 2, 2025 16:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants